home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-02-26 | 8.7 KB | 298 lines | [TEXT/MPS ] |
- // UDemoDialogs.cp
- // Copyright © 1990 by Apple Computer, Inc. All rights reserved.
-
- #ifndef __UDEMODIALOGS__
- #define __UDEMODIALOGS__
- #include "Sane.h"
- #include "UMacApp.h"
- #include "UPrinting.h"
- #include "UGridView.h"
- #include "UTEView.h"
- #include "UDialog.h"
- #include "ToolUtils.h"
- #include "Fonts.h"
- #include "Resources.h"
- #include "Packages.h"
- #include "StdIO.h"
- #include "StdLib.h"
- #include "Strings.h"
-
- #include "UGraph.h"
-
- // Command numbers
- const short cMakePicture = 1000;
-
- // Miscellaneous constants
- const unsigned long kSignature = 'SS01'; // Application signature
- const unsigned long kFileType = 'SF01'; // File-type code used for document files
- // created by this application
- const short kTestWindowID = 1001; /* This is passed to NewSimpleWindow as the
- resource ID of the the WIND Resource which
- defines the window for this application's
- documents */
-
- const short kMaxFonds = 100; // Max number of FONDs the FontList holds
-
- // typdefs
- typedef short FontList[kMaxFonds];
-
- typedef FontList *FontListPtr;
-
- // class declarations
- class TTestApplication : public TApplication {
- public:
-
- virtual pascal void ITestApplication(OSType itsMainFileType);
- /* Initializes the application and globals. */
-
- virtual pascal TCommand *DoMenuCommand(CmdNumber aCmdNumber);
-
- virtual pascal void DoSetupMenus(void);
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
-
- };
-
- class TNumbersView : public TView {
- public:
-
- virtual pascal void Draw(Rect *area);
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
-
- };
-
- class TMonthlyDialog : public TDialogView {
- public:
-
- virtual pascal TCommand *DoKeyCommand(short ch, short aKeyCode, EventInfo *info);
-
- virtual pascal Boolean DeselectCurrentEditText(void);
-
- virtual pascal void DismissDialog(ResType dismisser);
-
- virtual pascal void StuffValues(void);
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
-
- };
-
- class TModelessMarkDialog : public TDialogView {
- public:
-
- virtual pascal void DoChoice(TView *origView, short itsChoice);
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
-
- };
-
- class TFontListView : public TTextListView {
-
- public:
-
- virtual pascal void InitFontList();
- // Build an array of ids of font resources whose names are in alphabetical order
-
- virtual pascal void Free();
- // Make sure the font list gets freed
-
- virtual pascal void GetItemText(short anItem, StringPtr aString);
-
- virtual pascal void SelectItem(short anItem, Boolean extendSelection, Boolean highlight, Boolean select);
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr,
- short fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
-
- private:
-
- FontListPtr fFontList;
-
- };
-
- class TSizeListView : public TTextListView {
-
- public:
-
- virtual pascal void InitSizeList();
-
- virtual pascal void GetItemText(short anItem, StringPtr aString);
-
- virtual pascal void InstallFontFamily(short theFondIndex);
-
- virtual pascal void SelectItem(short anItem, Boolean extendSelection, Boolean highlight, Boolean select);
-
- virtual pascal void SetNumberOfItems(short aNumber);
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr,
- short fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
-
- private:
-
- short fSelection;
- short fSelectedSize;
- short fFondIndex;
-
- };
-
- class TPageSetupDialog : public TDialogView {
-
- public:
-
- TPageSetupDialog(); // constructor to initialize fOrientation
-
- virtual pascal void TPageSetupDialog::GetOrientation(VHSelect *theOrientation);
-
- virtual pascal void DoChoice(TView *origView, short itsChoice);
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
-
- private:
-
- VHSelect fOrientation;
-
- };
-
- class TRadioIcon :public TIcon {
- public:
-
- virtual pascal void TrackMouse(TrackPhase aTrackPhase, VPoint *anchorPoint, VPoint *
- previousPoint, VPoint *nextPoint, Boolean mouseDidMove);
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr,
- short fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- };
-
- class THomeBrewDialog : public TDialogView {
- public:
-
- virtual pascal Boolean DoSetCursor(Point localPoint, RgnHandle cursorRgn);
-
- virtual pascal TView *HandleCursor(VPoint *theMouse, RgnHandle cursorRgn);
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- };
-
- class TArrowsControl : public TPicture {
-
- public:
-
- virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
-
- virtual pascal void TrackMouse(TrackPhase aTrackPhase, VPoint *anchorPoint, VPoint *
- previousPoint, VPoint *nextPoint, Boolean mouseDidMove);
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
-
- private:
-
- long fLastChange; /* tick count of last call to DoChoice */
-
- };
-
- class TTemperatureCluster : public TCluster {
- public:
-
- virtual pascal void DoChoice(TView *origView, short itsChoice);
-
- virtual pascal long GetValue();
-
- virtual pascal void SetValue(long newValue, Boolean redraw);
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr,
- short fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- };
-
- class TTemperatureConversionCluster : public TCluster {
- public:
-
- virtual pascal void DoChoice(TView *origView, short itsChoice);
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr,
- short fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- };
-
- class TSlider : public TPicture {
-
- public:
-
- virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
-
- virtual pascal Boolean ContainsMouse(VPoint *theMouse);
-
- virtual pascal void Draw(Rect *area);
-
- virtual pascal void DrawKnob(void);
-
- virtual pascal void GetKnobRect(Rect *knobRect);
-
- virtual pascal void TrackMouse(TrackPhase aTrackPhase, VPoint *anchorPoint, VPoint *
- previousPoint, VPoint *nextPoint, Boolean mouseDidMove);
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr,
- short fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
-
- private:
-
- short fValue; // current value of slider
- PicHandle fKnobPicture; // handle to the PICT rsrc
- Rect fKnobRect; // rect within which we draw the knob
- short fMinTop;
- short fMaxTop;
-
- };
-
- class TSumStaticText : public TStaticText {
- public:
-
- virtual pascal void Draw(Rect *area);
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr,
- short fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- };
-
- class TCalcDialog : public TPicture {
-
- private: // since C++ allows enumerations with class scope, we'll take advantage of this:
-
- typedef enum {noOperator, divOperator, mulOperator, subOperator, addOperator} CalcOperator;
-
- public:
-
- virtual pascal void DoChoice(TView *origView, short itsChoice);
-
- virtual pascal TCommand *DoKeyCommand(short ch, short aKeyCode, EventInfo *info);
-
- virtual pascal void ClearSum(void);
-
- virtual pascal void FetchValue(long double *aValue);
-
- virtual pascal void SetValue(void);
-
- virtual pascal void TotalSum(CalcOperator newOperator);
-
- virtual pascal void NewDigit(short theNumber);
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
-
- private:
-
- long double fSum; // note: the ANSI C standard "long double" is preferred
- // over the IEEE standard "extended"
- long double fArgument; // current argument to the calculator
- CalcOperator fOperator; // operator for the equation
- Boolean fDecimalPoint; // whether or not a decimal point is in the number
- Boolean fRestart; // whether to restart entry of data (next number entered
- // corresponds to a new argument)
-
- };
-
- #endif
-